﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="CustomerArchives_AddVIP" Codebehind="AddVIP.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <style type="text/css">
fieldset {width:96%;}
select {margin:0;padding:0;}
body{padding:0; margin:0; background-color:#ffffff; text-align:center; font: "宋体"; font-size:12px;}
a:visited{text-decoration:none;color:slategray;}
a:hover{text-decoration:underline;color:slategray;}
a:link{text-decoration:none;color:slategray;}
.juli {margin-top:10px;padding-left:20px;}
.juli1 {margin-top:20px; margin-left:20px; text-align:left;}
.juli2 { margin:5px auto;}
.juli3 { margin-bottom:50px;}
.juli4 {padding-left:20px;padding-top:20px;padding-bottom:10px;background-color:#fef3bb;}
.juli5 {padding:0px; margin:0px;}
.z1{background-color:#e7e7e7; text-align:left; line-height:20px;}
.z2{background-color:#FFFFFF; text-align:left; line-height:20px;}
.input_button {width:52px;height:23px;border:none;cursor:pointer; background:#ffffff url(../../Include/Images/bt.gif) no-repeat;}
.input_button1 {width:74px;height:23px;border:none;cursor:pointer; background:#ffffff url(../../Include/Images/bt1.gif) no-repeat;}
.input_button2 {width:52px;height:23px;border:none;background:#ffffff url(../../Include/Images/bt.gif) no-repeat; padding-top:5px;}
.input_button2 a{color:#000000;}
.input_button2 a:hover{color:#FF3300; text-decoration:underline;}
.input_button3 {width:95px;height:23px;border:none;background:#ffffff url(../../Include/Images/bt2.gif) no-repeat;}
.zt1 {padding-left:10px; font-weight:600; color:#000000;}
.zt2 {padding-left:10px;}
.zt3 {text-align:center; font-weight:600; color:#000000;}
.zt4 {text-align:center; color:#000000;}
.zt5 {text-align:left; font-weight:600;}
.zt6 {font-size:14px; font-weight:600;}
.zt7 {text-align:right; color:#000000;}
.zt8 {text-align:right; color:#000000;}
.spmenu { line-height:28px; text-align:center;margin-bottom:10px; border-color:#999999;}
.menu_bg {background-color:#fef3bb; padding-left:20px;padding-top:6px; padding-bottom:6px;border-bottom:#cf994b 1px solid;}
.menu_bg1 { background-color:#fef3bb; padding-left:20px;padding-top:6px; padding-right:20px;border-bottom:#cf994b 1px solid; height:28px;}
.tb {width: 90%; background-color:#999999;}
.tb1 {width: 90%; background-color:#999999; margin-top:10px;}
.tb2 {width: 1050px; background-color:#999999;}
.left {float:left; clear:right;}
.k1 {float:left;width:90%; background-color:#efefef; border:#999999 1px solid;padding-top:10px;}
.k2 {float:left; width:90%; line-height:28px; margin-top:10px;}
.k3 {float:left; width:90%; line-height:28px; margin-top:10px; padding-bottom:30px; clear:both;}
.btlj1 {background: url(../../Include/Images/bt1.gif) no-repeat; color:#000000; width:74px; height:23px;text-align:center; padding-top:5px; font-size:12px; display:inline; float:left;margin-left:5px;}
.btlj1 a{color:#000000; text-decoration:none;}
.btlj1 a:hover{color:#FF3300;text-decoration:underline;}
.hidden{visibility:hidden;}
a.lj {font-size:12px; color:#ff9900; text-decoration:underline;}
a.lj:link {font-size:12px; color:#ff9900; text-decoration:underline;}
a.lj:visited {font-size:12px; color:#ff9900; text-decoration:underline;}
a.lj:hover {color:#ff3300;}
a.lj:active {color:#ff3300;}
h2 {padding-left:20px;padding-top:10px;margin:0; background: url(../../Include/Images/menu_title.gif) repeat-x;height:21px;font-size:14px; font-weight:600;}
.menu_bg3 { background-color:#f5f5f5; padding-left:20px;padding-top:6px; padding-bottom:6px;border-bottom:#cccccc 1px solid;border-top:#cccccc 1px solid;clear:left;}
</style>
</head>
<body>
    <form id="form1" runat="server">

        <script type="text/javascript" src="../Include/JS/Lib/jquery-1.1.4.js"></script>

        <script type="text/javascript" src="../Include/JS/Address.js"></script>

        <script type="text/javascript">
var  $j = jQuery.noConflict();
function InitProvince()
{
    var options = address[0][0];
    var arr_option = options.split("&&");
    var sel = document.getElementById("Province");
    while( sel.value>-1 )
    {
        sel.removeChild(sel.options(0));        
    }
    sel.options[0]=new Option("请选择","-1");
    for(var i = 1; i < arr_option.length;i++)
    {
        eval("sel.options[i] = new Option" + arr_option[i-1] +";");
    }
}
function RegAddress_Init()
{  
     $j.post("../Handler/AddressHandler.ashx", {OP:"RegAddress"},
            function(data){                          
               eval(data);
               InitProvince();
            }
        );
}
function GetRegAreaList(value,selectvalue)
{
    LoadArea=false;
    if(parseInt(value)>-1)
    {
        $j.post("../Handler/AddressHandler.ashx", {City:value, OP:"Area"},
                function(data){                          
                   InitArea(data,selectvalue);
                }
            );
     }
     else
     {
        var sel = document.getElementById("Area"); 
    
        while( sel.length>0 )
        {
            sel.removeChild(sel.options(0));
            
        }
        sel.options[0]=new Option("请选择","-1");
     }
}
function Clear(obj)
{
    if(obj.value=="区号"||obj.value=="号码"||obj.value=="分机")
    {
        obj.value="";
    }
}
function Check()
{
  debugger;
    var UserCode=document.getElementById("txtAccounts");
    var userName = document.getElementById("txtUserName");
    var province = document.getElementById("Province");
    var city =  document.getElementById("City");
    var area = document.getElementById("Area");
    var address = document.getElementById("txtAddress");
    var postCode = document.getElementById("txtPostCode");
    var mobile = document.getElementById("txtMobile");
    var phone = document.getElementById("txtPhone");
    var phone1 = document.getElementById("txtPhone1");
    var phone2 = document.getElementById("txtPhone2");
    var nike=document.getElementById("txtNike");
    var hidden1 = document.getElementById("hidIsAutoCreateCustomerAccount");
    var hidden2 = document.getElementById("hidAutoCreateAccountPassword");
    if(hidden1.value=="0")
    {
        if(UserCode.value.length<1)
        {
            alert("会员账号不能为空");
            UserCode.focus();
            return false;
        }
    }
    if(nike.value.length>50)
    {
        alert("昵称长度不能超过50位，汉字25位");
        nike.focus();
        return false;
    }
    if(UserCode.value.length>20)
    {
        alert("会员账号长度不能超过20位");
        UserCode.focus();
        return false;
    }
    var pattern = /[^0-9a-z.@A-Z]/g;
    if(pattern.test(UserCode.value))
    {
        alert("会员账号只能输入数据(0-9)或字母(a-z或A-Z)");
        UserCode.focus();
        return false;
    }
    if(province.selectedIndex<1)
    {
        alert("请选择省份");
        province.focus();
        return false;
    }
    if(city.selectedIndex<1)
    {
        alert("请选择城市");
        city.focus();
        return false;
    }
    if(area.selectedIndex<1)
    {
        alert("请选择区县");
        area.focus();
        return false;
    }
    
    if(address.value.length<1)
    {
        alert("详细地址不能为空");
        address.focus();
        return false;
    }
    if(postCode.value.length>0)
    {
        var pattern =/^[0-9]\d{5}$/;
        if(!pattern.test(postCode.value))
        {
            alert("请输入正确的6位数邮政编码！");
            postCode.focus();
            return false;
        }
    }
    
     if((phone1.value.length==0||phone1.value=="号码")&&mobile.value.length==0)
     {
        alert("固定电话或手机号必填一个");
        return false;
     }
    if(phone.value.length>0&&phone.value!="区号"||phone1.value.length>0&&phone1.value!="号码"||phone2.value.length>0&&phone2.value!="分机")
    {debugger;
    if((phone.value.length>0&&phone.value!="区号")||(phone1.value.length>0&&phone1.value!="号码"))
    {
        if(isNaN(phone.value)||isNaN(phone1.value))
        {
            alert("固定电话格式错误,请检查您输入法的全角/半角状态！");
            return false;
        }
        var reg=/^\d{3,4}$/;//检查区号

        var reg1=/^\d{7,8}$/;//检查电话号码

        if(!reg.test(phone.value)||!reg1.test(phone1.value))
        {
            alert("固定电话格式错误");
            return false;
        }
    }
    if(phone2.value.length>0&&phone2.value!="分机")
    {
        if(isNaN(phone.value)||isNaN(phone1.value)||isNaN(phone2.value))
        {
            alert("固定电话格式错误,请检查您输入法的全角/半角状态！");
            return false;
        }
        var reg=/^\d{3,4}$/;//检查区号

        var reg1=/^\d{7,8}$/;//检查电话号码

        var reg2=/^\d{1,5}$/;//检查分机号
        if(!reg.test(phone.value)||!reg1.test(phone1.value)||!reg2.test(phone2.value))
        {
            alert("固定电话格式错误");
            return false;
        }
    }
    }
    if(mobile.value.length>0)
    {
        if(isNaN(mobile.value))
        {
            alert("手机号码含有非法字符");
            mobile.focus();
            return false;
        }
        var reg=/^\d+$/;//检查手机

        if(!reg.test(mobile.value))
        {
            alert("请输入正确的手机号码");
            mobile.focus();
            return false;
        }
    }
    
    
    var Sex0=document.getElementById("rblSex_0");
    var Sex1=document.getElementById("rblSex_1");
    var sexvalue;
    if(!Sex0.checked&&!Sex1.checked)
    {
        alert("请选择性别");
        return false;
    }
    if(Sex0.checked)
    {
        sexvalue="男";
    }
    if(Sex1.checked)
    {
        sexvalue="女";
    }
    
    var Password1=document.getElementById("Password1");
    var Password2=document.getElementById("Password2");
    if(hidden2.value=="0")
    {
        if(Password1.value.length<1)
        {
            alert("密码不能为空");
            Password1.focus();
            return false;
        }
        if(Password2.value.length<1)
        {
            alert("确认密码不能为空");
            Password2.focus();
            return false;
        }
        if(Password1.value!=Password2.value)
        {
            alert("两次输入密码不一致");
            Password1.focus();
            return false;
        }
    }
    if(userName.value.length<1)
    {
        alert("会员真实姓名不能为空");
        userName.focus();
        return false;
    }
    var txtEmail=document.getElementById("txtEmail");
    if(txtEmail.value.length>1)
    {
        var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
        var flag = pattern.test(txtEmail.value); 
        if(!flag)
        {
            alert("Email格式不正确!");
            txtEmail.focus();
            return false;
        }
    }
    var source="";
    var select1 = document.getElementById("Select1");
    for(var i=0;i<select1.options.length;i++)
    {
        if(select1.options[i].selected)
        {
            source = select1.options[i].value;
            break;
        }
    }
    Mask();    
    document.getElementById("ShoppingCart").innerHTML="<br /><br />数据加载中......<br />";
    var phone0="";
        if(phone1.value.length>0&&phone1.value!="号码")
        {
            phone0=phone.value+"-"+phone1.value;            
        }
        if(phone2.value.length>0&&phone2.value!="分机")
        {
            phone0=phone.value+"-"+phone1.value+"-"+phone2.value;
        }
    CallServer(UserCode.value,sexvalue,Password1.value,txtEmail.value,userName.value,province.value,city.value,area.value,address.value,postCode.value,mobile.value,phone0,nike.value,source);    
}
function NameTS(value,color)
{
    document.getElementById("Name").innerHTML="<span  style=\"color:"+color+"\">"+value+"</span>";
}
function Mask()
{ 
    var div_back = document.getElementById("div_background");
    div_back.style.display = "block"; 
    var iframe_back = document.getElementById("iframe_back");
    iframe_back.style.display = "block";  
    var sizeList = document.getElementById("Submit"); 
    sizeList.disabled = true; 
    var cart = document.getElementById("ShoppingCart");
    cart.style.display = "block";
    cart.style.position = "absolute";
    var bigImg = document.getElementById("Rg");
    var pleft = 0;
    var ptop = 0;
   
    var obj = bigImg.offsetParent;
 
    while(obj.tagName != "BODY")
    {
         pleft = pleft + obj.offsetLeft;
         ptop = ptop + obj.offsetTop;
         obj = obj.offsetParent;
    }
    ptop = ptop + 150;
    cart.style.left = pleft +100+ "px";
    cart.style.top = ptop +"px";
    cart.style.width = 300 + "px";
    cart.style.backgroundColor  = "#ffffff";
}
function hide()
{
  var div_back = document.getElementById("div_background");
    div_back.style.display = "none"; 
     var iframe_back = document.getElementById("iframe_back");
    iframe_back.style.display = "none";   
    var sizeList = document.getElementById("Submit"); 
    sizeList.disabled = false;
    var cart = document.getElementById("ShoppingCart");
    cart.style.display = "none";    
}
function CallServer(UserCode,Sex,Pwd,Email,userName,Province,City,Area,address,postCode,mobile,phone,nike,source)  
{ 
      arg = UserCode+"|"+Sex+"|"+Pwd+"|"+Email+"|"+userName+"|"+Province+"|"+City+"|"+Area+"|"+address+"|"+postCode+"|"+mobile+"|"+phone+"|"+nike+"|"+source;   
      <%= ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "")%>;   
}   
 function ReceiveServerData(result)   
 {  
     switch (result)
     {
        case "-2":
            hide(); 
            alert("信息中有空值")  ;
            break;
        case "-1":
            hide(); 
            alert("网站配置信息有错,请联系管理员");
            break;
        case "0":
            hide();
            alert("注册失败");
            break;
        case "1":
            hide();
            alert("账号有重复");
            break;
        case "2":
            hide();
            alert("Email有重复");
            break;
        case "3":
            hide();
            alert("昵称有重复");
            break;
        default:
            if(document.getElementById("HiddenField1").value=="1")
            {
                var arr=result.split(",");
                var url=encodeURI("../Order/NewOrder.aspx?accountcode="+arr[0]+"&zk="+arr[1]+"&gkmc="+arr[2]+"&nike="+arr[3]);
                window.location.href=url;
            }
            else
            {
                alert("成功");
            } 
            
     }
     
 } 
 RegAddress_Init();
        </script>

        <div align="Justify">
            <div>
                <div>
                    <h2>
                        会员注册</h2>
                </div>
                <div class="menu_bg">
                    <div id="Rg">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="100" align="right">
                                    会员账号：</td>
                                <td width="200">
                                    <%--<input id="txtAccounts" name="txtAccounts" class="inputbox" onclick="NameTS('请输入数字或字母,长度不要超过20位','Green')" runat="server">*--%>
                                    <asp:TextBox ID="txtAccounts" CssClass="inputbox" onclick="NameTS('请输入数字或字母,长度不要超过20位','Green')"
                                        runat="server"></asp:TextBox>*
                                </td>
                                <td class="r_reg_icon" id="Name">
                                    <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    性别：</td>
                                <td>
                                    <input id="rblSex_0" type="radio" checked value="男" name="rblSex">
                                    <label for="rblSex_0">
                                        男</label><input id="rblSex_1" type="radio" value="女" name="rblSex">
                                    <label for="rblSex_1">
                                        女</label></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    密码：</td>
                                <td>
                                    <asp:TextBox ID="Password1" TextMode="Password" CssClass="inputbox" runat="server"></asp:TextBox></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    密码确认：</td>
                                <td>
                                    <asp:TextBox ID="Password2" TextMode="Password" CssClass="inputbox" runat="server"></asp:TextBox></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    &nbsp;&nbsp;&nbsp;Email：</td>
                                <td>
                                    <input id="txtEmail" name="txtEmail" class="inputbox"></td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px;" align="right">
                                    会员昵称：</td>
                                <td style="height: 10px">
                                    <input id="txtNike" name="txtNike" class="inputbox"></td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    会员真实姓名：</td>
                                <td style="height: 10px">
                                    <input id="txtUserName" type="text" />*</td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    地址：</td>
                                <td>
                                    <div style="float: left;">
                                        <select id="Province" onchange="GetCityList(this.value)">
                                            <option value="-1">请选择</option>
                                        </select>
                                        <select id="City" onchange="GetRegAreaList(this.value)">
                                            <option>请选择</option>
                                        </select>
                                        <select id="Area">
                                            <option>请选择</option>
                                        </select>
                                        *
                                    </div>
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    详细地址：</td>
                                <td style="height: 10px">
                                    <input id="txtAddress" type="text" size="45"/>*</td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    邮编：</td>
                                <td style="height: 10px">
                                    <input id="txtPostCode" type="text" /></td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    手机：</td>
                                <td style="height: 10px">
                                    <input id="txtMobile" type="text" /></td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    固定电话：</td>
                                <td style="height: 10px">
                                <input id="txtPhone" type="text" value="区号" size="5"  onfocus="Clear(this)" />
                                <input id="txtPhone1" type="text" value="号码" size="14"  onfocus="Clear(this)" />
                                <input id="txtPhone2" type="text" value="分机" size="14" onfocus="Clear(this)" />
                    </td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr height="10">
                                <td style="height: 10px" align="right">
                                    客户来源：

                                </td>
                                <td style="height: 10px">
                                    <select id="Select1" runat="server">
                                        
                                    </select>
                                </td>
                                <td style="height: 10px">
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <a href="javascript:" class="btlj1" onclick="Check()" id="Submit">提交注册</a></td>
                                <td>
                                </td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="clear">
                </div>
            </div>
        </div>
        <div id="div_background" class="divbackground" onclick="hide();">
        </div>
        <iframe id="iframe_back" class="diviframe" frameborder="0"></iframe>
        <div id="ShoppingCart" style="z-index: 11; display: none">
        </div>
        <asp:HiddenField ID="HiddenField1" runat="server" />
        <input id="hidIsAutoCreateCustomerAccount" type="hidden" runat="server" />
        <input id="hidAutoCreateAccountPassword" type="hidden" runat="server" />
    </form>
</body>
</html>
